<%@ page import="com.starry.Person" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>JSP - Hello World</title>
</head>
<body>
<h1><%= "Hello World!" %>
</h1>
<br/>
<a href="hello-servlet">Hello Servlet</a>
<%
    Person p=new Person("luffy");
    p.setBanks(new String[]{"招商银行","建设银行","农业银行"});
    List<String> myhobbys=new ArrayList<String>();
    myhobbys.add("篮球");
    myhobbys.add("羽毛球");
    myhobbys.add("乒乓球");
    p.setHobbys(myhobbys);
    Map<String,Object> maps=new HashMap<String,Object>();
    maps.put("key1","A");
    maps.put("key2","B");
    p.setMaps(maps);

    pageContext.setAttribute("onep",p);
%>
<h1>JSP脚本方式</h1>
<%
    Person instanceP=(Person)(pageContext.getAttribute("onep"));
%>
<%= "获取p:"+pageContext.getAttribute("onep")%><br/>
<%= "获取p的username属性:"+((Person)(pageContext.getAttribute("onep"))).getUserName()%><br/>
<%= "获取p的banks字符串数组第一个值:"+instanceP.getBanks()[0]%><br/>
<%= "获取p的hobbys集合:"+instanceP.getHobbys()%><br/>
<%= "获取p的hobbys集合第一个值:"+instanceP.getHobbys().get(0)%><br/>
<%= "获取p的maps:"+instanceP.getMaps()%><br/>
<%= "获取p的maps的某个key的值:"+instanceP.getMaps().get("key1")%><br/>

<%= "获取p的age的值:"+instanceP.getAge()%><br/>
<h1>EL表达式方式</h1>
获取P:${onep}<br/>
获取p的username属性:${onep.userName}<br/>
获取p的banks字符串数组第一个值:${onep.banks[0]}<br/>
获取p的hobbys集合:${onep.hobbys}<br/>
获取p的hobbys集合第一个值:${onep.hobbys[0]}<br/>
获取p的maps :${onep.maps}<br/>
获取p的maps的某个key的值 :${onep.maps.key1}<br/>

获取p的age的值 :${onep.age}<br/>
</body>
</html>